package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/logout")
public class LogOutServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //清除session
        req.getSession().invalidate();
        //跳转页面
        //因为页面为frame框架模式，所以重定向后不能退出所有框架
        //resp.sendRedirect("login.jsp");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println("<script>top.location.href='login.jsp';</script>");

    }
}
